<template>
  <e-container>
    <a-space :size="24">
      <a-button size="small" @click="() => router.push({ name: 'Configuration', params: { id: route.params.id } })">
        <template #icon>
          <e-icon type="Aright" />
        </template>
      </a-button>
      <e-title title="Blacklist History" />
    </a-space>
    <div class="table">
      <a-row>
        <a-col :span="3" class="cell field">Type</a-col>
        <a-col :span="3" class="cell field">Time</a-col>
        <a-col :span="3" class="cell field">Operator</a-col>
        <a-col :span="3" class="cell field">Operation</a-col>
        <a-col :span="12" class="cell field">Reason</a-col>
      </a-row>
      <a-row v-for="(record, index) in records" :key="index">
        <a-col :span="3" class="cell">{{ record.blackListTypeName }}</a-col>
        <a-col :span="3" class="cell">{{ record.createOn }}</a-col>
        <a-col :span="3" class="cell">{{ record.operator }}</a-col>
        <a-col :span="3" class="cell">{{ record.operation }}</a-col>
        <a-col :span="12" class="cell">{{ record.reason }}</a-col>
      </a-row>
    </div>
  </e-container>
</template>

<script setup>
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import EContainer from '@/components/EContainer.vue'
import EIcon from '@/components/EIcon.vue'
import ETitle from '@/components/ETitle.vue'
import Configuration from '@/api/client/configuration.js'
const route = useRoute()
const router = useRouter()
const { id } = route.params
const records = ref([])
Configuration.getOperateRecords(id).then(({ data }) => {
  records.value = data
})
</script>

<style lang="less" scoped>
@border: 1px solid @lighter-gray;
.table {
  border: @border;
  margin-top: 24px;
  .cell {
    padding: 10px 14px;
    border-bottom: @border;
    border-right: @border;
    &:last-child {
      border-right: none;
    }
    &.field {
      background-color: @milk;
      color: @text-gray;
    }
  }
  .ant-row:last-child {
    .cell {
      border-bottom: none;
    }
  }
  .ant-tag {
    background-color: @phase-default;
    border: none;
    padding: 1px 12px;
    font-size: 14px;
    .e-icon {
      color: @primary-color !important;
      cursor: pointer;
    }
  }
}
</style>
<route lang="yaml">
name: 'Blacklist History'
path: '/client/:id/configuration/blacklist-history'
meta:
  title: 'Blacklist History'
  permission: Configuration
</route>
